home *** CD-ROM | disk | FTP | other *** search
/ Champak 125 / Vol 125 (Damaged).iso / games / spiderma.swf / scripts / frame_8 / DoAction.as
Encoding:
Text File  |  2008-11-13  |  5.8 KB  |  232 lines

  1. stop();
  2. score = 0;
  3. julspeed = 55;
  4. spider_julNum = 0;
  5. spidermove = 0;
  6. batmove = 0;
  7. v = 55;
  8. t = 0;
  9. tx = 0;
  10. gravitation = 30;
  11. tadd = 0.35;
  12. life = 0;
  13. endNum = 0;
  14. hitNum = 0;
  15. timeNum = 0.5;
  16. timewidth = time._width;
  17. julNum = 1;
  18. timecon = 0;
  19. live = 0;
  20. pressSounds = new Sound();
  21. pressSounds.attachSound("presssound");
  22. hitSounds = new Sound();
  23. hitSounds.attachSound("hitsound");
  24. deaths = new Sound();
  25. deaths.attachSound("death");
  26. julpoz.attachMovie("jul_spider","jul0",0);
  27. spider_randx = random(50) + 450;
  28. julpoz.jul0._x = spider_randx;
  29. julpoz.jul0.jul_speed = random(7) + 5;
  30. julpoz.attachMovie("jul_bat","jul" + julNum,julNum);
  31. bat_randx = random(50) + 150;
  32. julpoz["jul" + julNum]._x = bat_randx;
  33. julpoz.jul0.onEnterFrame = function()
  34. {
  35.    spider_julNum += julpoz.jul0.jul_speed;
  36.    this._rotation = julspeed * Math.cos(spider_julNum * 0.017453292519943295) + 90;
  37.    if(spider_julNum > 360)
  38.    {
  39.       spider_julNum -= 360;
  40.    }
  41.    if(spidermove == 0)
  42.    {
  43.       spiderman._rotation = this._rotation;
  44.       spidermanangle = spiderman._rotation;
  45.       poz = new Object();
  46.       poz.x = this.point._x;
  47.       poz.y = this.point._y;
  48.       this.localToGlobal(poz);
  49.       spiderman._x = poz.x;
  50.       spiderman._y = poz.y;
  51.       spacepress = 0;
  52.    }
  53.    if(_root.spidermove == 2)
  54.    {
  55.       this._x += 5;
  56.    }
  57.    if(this._x > 750)
  58.    {
  59.       this.removeMovieClip();
  60.    }
  61. };
  62. spiderman.onKeyDown = function()
  63. {
  64.    if(Key.getCode() == 32)
  65.    {
  66.       if(spidermove == 0 & spacepress == 0)
  67.       {
  68.          pressSounds.start(0,1);
  69.          if(spider_julNum > 180)
  70.          {
  71.             t = 0;
  72.             tx = 0;
  73.             spidermanstartx = this._x;
  74.             spidermanstarty = this._y;
  75.             jumpangle = 360 - spidermanangle - 90;
  76.             spidermove = 1;
  77.             this.gotoAndStop("jump");
  78.          }
  79.          else
  80.          {
  81.             t = 0;
  82.             tx = 0;
  83.             spidermanstartx = this._x;
  84.             spidermanstarty = this._y;
  85.             jumpangle = 360 - spidermanangle + 90;
  86.             spidermove = 1;
  87.             this.gotoAndStop("miss");
  88.          }
  89.          spacepress = 1;
  90.       }
  91.       if(spidermove == 2 & spacepress == 0)
  92.       {
  93.          pressSounds.start(0,1);
  94.          if(_root.julpoz["jul" + (_root.julNum - 1)].bat_julNum > 180)
  95.          {
  96.             t = 0;
  97.             tx = 0;
  98.             spidermanstartx = this._x;
  99.             spidermanstarty = this._y;
  100.             jumpangle = 360 - spidermanangle - 90;
  101.             spidermove = 1;
  102.             this.gotoAndStop("jump");
  103.          }
  104.          else
  105.          {
  106.             t = 0;
  107.             tx = 0;
  108.             spidermanstartx = this._x;
  109.             spidermanstarty = this._y;
  110.             jumpangle = 360 - spidermanangle + 90;
  111.             spidermove = 1;
  112.             this.gotoAndStop("miss");
  113.          }
  114.          spacepress = 1;
  115.       }
  116.    }
  117. };
  118. Key.addListener(spiderman);
  119. spiderman.onEnterFrame = function()
  120. {
  121.    if(spidermove == 1 && endNum == 0)
  122.    {
  123.       t += 0.25;
  124.       tx += tadd;
  125.       vy0 = v * Math.sin(jumpangle * 3.141592653589793 / 180);
  126.       vx0 = v * Math.cos(jumpangle * 3.141592653589793 / 180);
  127.       vy = vy0 - _root.gravitation * t;
  128.       this._x = spidermanstartx + vx0 * tx;
  129.       this._y = spidermanstarty - vy0 * t + 0.5 * _root.gravitation * t * t;
  130.       this._rotation = Math.atan((- vy) / vx0) * 180 / 3.141592653589793;
  131.       if(julpoz["jul" + julNum].hit.hitTest(this))
  132.       {
  133.          hitSounds.start(0,1);
  134.          _root.julNum = _root.julNum + 1;
  135.          spidermove = 2;
  136.          timecon = 0;
  137.          hitNum = 1;
  138.          time._width = timewidth;
  139.          score += 20;
  140.       }
  141.    }
  142.    if(this._y >= 200 & live == 0)
  143.    {
  144.       deaths.start(0,1);
  145.       live = 1;
  146.    }
  147.    if(this._y >= 400)
  148.    {
  149.       this._y = 400;
  150.       life++;
  151.       die.gotoAndPlay(2);
  152.       if(life < 5)
  153.       {
  154.          eval("life" + life)._visible = 0;
  155.          t = 0;
  156.          tx = 0;
  157.          timecon = 0;
  158.          if(julNum <= 1)
  159.          {
  160.             spidermove = 0;
  161.          }
  162.          else
  163.          {
  164.             spidermove = 2;
  165.          }
  166.          time._width = timewidth;
  167.          this.gotoAndStop("ready");
  168.          live = 0;
  169.       }
  170.       if(life == 5)
  171.       {
  172.          eval("life" + life)._visible = 0;
  173.          theend.gotoAndPlay(2);
  174.          endNum = 1;
  175.       }
  176.    }
  177. };
  178. time.onEnterFrame = function()
  179. {
  180.    if(this._width > timeNum & spidermove != 1)
  181.    {
  182.       this._width -= timeNum;
  183.    }
  184.    if(this._width <= timeNum && timecon == 0)
  185.    {
  186.       if(spider_julNum > 180)
  187.       {
  188.          t = 0;
  189.          tx = 0;
  190.          spidermanstartx = spiderman._x;
  191.          spidermanstarty = spiderman._y;
  192.          jumpangle = 360 - spidermanangle - 90;
  193.          spidermove = 1;
  194.          spiderman.gotoAndStop("jump");
  195.       }
  196.       else
  197.       {
  198.          t = 0;
  199.          tx = 0;
  200.          spidermanstartx = spiderman._x;
  201.          spidermanstarty = spiderman._y;
  202.          jumpangle = 360 - spidermanangle + 90;
  203.          spidermove = 1;
  204.          spiderman.gotoAndStop("miss");
  205.       }
  206.       if(spidermove == 2)
  207.       {
  208.          if(_root.julpoz["jul" + (_root.julNum - 1)].bat_julNum > 180)
  209.          {
  210.             t = 0;
  211.             tx = 0;
  212.             spidermanstartx = spiderman._x;
  213.             spidermanstarty = spiderman._y;
  214.             jumpangle = 360 - spidermanangle - 90;
  215.             spidermove = 1;
  216.             spiderman.gotoAndStop("jump");
  217.          }
  218.          else
  219.          {
  220.             t = 0;
  221.             tx = 0;
  222.             spidermanstartx = spiderman._x;
  223.             spidermanstarty = spiderman._y;
  224.             jumpangle = 360 - spidermanangle + 90;
  225.             spidermove = 1;
  226.             spiderman.gotoAndStop("miss");
  227.          }
  228.       }
  229.       timecon = 1;
  230.    }
  231. };
  232.